const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');

const app = express();
app.use(cors())

app.use(express.urlencoded({extended: false}))
app.use(bodyParser.json())

const phoneRouter = require('./router/phone')
app.use('/api', phoneRouter)

const userRouter = require('./router/userInfo')
app.use('/api/user', userRouter)

// 处理用户登录注册相关的路由
const adminRouter = require('./router/admin')
app.use('/api/admin', adminRouter)

// 商品相关的路由
const mallRouter = require('./router/mall')
app.use('/api/mall', mallRouter)

app.listen(3002, ()=> {
    console.log('api server running at http://127.0.0.1:3002')
})